package com.li.blog.config;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

import java.util.ArrayList;

@Configuration //配置类
@EnableKnife4j
@EnableSwagger2WebMvc// 开启Swagger2的自动配置
public class SwaggerConfig {
    /**
     *  访问地址 http://localhost:8081/doc.html
     * @return
     */
    @Bean//配置docket以配置Swagger具体参数
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2).
                apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.li.blog.controller"))
                .build()
                ;
    }
    private ApiInfo apiInfo() {
        Contact contact = new Contact("李洋静", "https://blog.csdn.net/weixin_45545764?spm=1001.2101.3001.5343", "958390434@qq.com");
        return new ApiInfo(
                "博客系统接口文档", // 标题
                "我设计的博客管理系统", // 描述
                "v1.0", // 版本
                "http://terms.service.url/组织链接", // 组织链接
                contact, // 联系人信息
                "Apach 2.0 许可", // 许可
                "许可链接", // 许可连接
                new ArrayList<>()// 扩展
        );
    }
}
